from  neo4j.FastNeo4j import FastNeo4j
from py2neo import Graph, Node, Relationship, cypher, Path,Subgraph,NodeMatcher

class AiPack():
    f4= FastNeo4j()

    def __init__(self):

        return


    def createNode(self,node:Node):

        n=self.f4.findOne(*node.labels,name=node['name'])
        print(n)
        if n is None:
            self.f4.addNode(node)
        else:
            self.f4.updateByNode(node)

    def getNode(self,label,name):

        return  self.f4.findOne(label=label, name=name)

    def delNode(self, *nodes):

        return self.f4.delNodes(*nodes)
    d

if __name__ == "__main__":
    ap=AiPack()
    #ap.createRoot();
    # node:Node=Node("concept",name="object")
    # # ap.f4.addlabel("pp",node)
    # ap.createNode(node)
    # print(node)
    # lst=list()
    # lst.append(node)
    # ap.delNode(*lst)
    # #ap.f4.updateNode(node,type=5,age=122)
    # ap.createNode("language",name='adj')
    # n:Node=ap.f4.findOne("language",name='adj')
    # labels=n.labels
    # for l in labels:
    #     print(l)
    #
    # print(type(labels))
    node=ap.f4.matchItembyLabel("concept",name='object')
    print(node)
